package com.zz.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import com.zz.entity.Warning;

public interface WarningRepository extends JpaRepository<Warning, String> {
	@Query(value="select pr.id,pr.name,pr.num,w.status,w.maxnum,w.minnum from warning as w right join product pr on (pr.id=w.product_id) where pr.name=?1",
		    countQuery = "SELECT count(*) FROM product where name=?1",
			nativeQuery = true)
	public Page<Object[]> showWarninglistByProName(String name,Pageable pageable);
	@Query(value="select pr.id,pr.name,pr.num,w.status,w.maxnum,w.minnum from warning as w right join product pr on (pr.id=w.product_id)",
			countQuery = "SELECT count(*) FROM product",
			nativeQuery = true)
	public Page<Object[]> showWarninglist(Pageable pageable);
}
